﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace Quản_Lý_Thư_Viện
{
    public partial class frmThongTinSach : Form
    {
        public frmThongTinSach()
        {
            InitializeComponent();
        }

        SachControl scontrol = new SachControl();
        DataTable dt = new DataTable();
        ConhieuControl cncontrol = new ConhieuControl();
        
        private void frmThongTinSach_Load(object sender, EventArgs e)
        {

            DataTable dt2 = new DataTable();
            dt2 = cncontrol.layTG();
            string temp = "";
            for (int i = 0; i < dt2.Rows.Count; i++)
            {
                temp = temp + dt2.Rows[i]["TENTG"].ToString();
                temp = temp + " , ";
            }

            dt = scontrol.laythongtinsach();
            DataRow dr = dt.Rows[0];
            lbl_tensach.Text = dr["TENSACH"].ToString();
            lbl_namxuatban.Text = dr["NAMXB"].ToString();
            lbl_nhaxuatban.Text = dr["NXB"].ToString();
            lbl_theloai.Text = dr["TENTHELOAI"].ToString();
            lbl_trigia.Text = dr["TRIGIA"].ToString();
            lbl_tacgia.Text = temp;
            byte[] b = (byte[])dr["HINHANH"];
            MemoryStream st = new MemoryStream();
            st.Write(b, 0, b.Length);
            Image im = Image.FromStream(st);
            picSach.Image = im;
        }
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == (Keys.Escape))
            {
                this.Close();
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }
    }
}
